package cn.tedu.rms.tables.pojo.vo;

import cn.tedu.rms.base.enums.ReservationTimes;

import javax.swing.plaf.synth.SynthOptionPaneUI;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;

public class Test {
    public static void main(String[] args) {

        /*String time = "20:00:00";
        String time1 = "23:59:59";

        Date date = new Date();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm:ss");
        String format = simpleDateFormat.format(date);

        System.out.println(format);
        System.out.println(time);

        System.out.println(time.compareTo(format));*/


        /*获取当前系统时间*/
        Date date = new Date();

        /*按照固定格式进行转换*/
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss SSS");
            /*UTC时区打印UTC时间*/
        simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
        //simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT+8"));

            /*Date--->字符串*/
        String dateFormat = simpleDateFormat.format(date);
        System.out.println("Date转为字符串格式===>"+dateFormat);
            /*字符串--->Date*/
        String dateStr = "2024-11-25 10:06:53 000";
        try {
            Date dateStrToDate = simpleDateFormat.parse(dateStr);
            System.out.println("字符串时间转为Date格式===>"+dateStrToDate);
        } catch (ParseException e) {
            e.printStackTrace();
        }

        /*获取当前时间的时间戳*/
        long time = date.getTime();
        System.out.println(time);

        String time1970 = "1970-1-1 08:00:00 000";
        try {
            Date parse = simpleDateFormat.parse(time1970);
            System.out.println("1970--->"+parse.getTime());
        } catch (ParseException e) {
            e.printStackTrace();
        }

    }

}
